//
//  CalenderWeekView.m
//  YZCCalender
//
//  Created by Jason on 2018/1/17.
//  Copyright © 2018年 jason. All rights reserved.
//

#import "CalenderWeekView.h"

@interface CalenderWeekView ()

@end

@implementation CalenderWeekView

- (void)setDataSource:(NSArray *)dataSource {
    _dataSource = dataSource;
    for (UIView *view in self.subviews) {
        if ([view.class isKindOfClass:UILabel.class]) {
            [view removeFromSuperview];
        }
    }
    
    CGFloat count  = dataSource.count;
    CGFloat labelW = MS_SCREEN_WIDTH / count;
    CGFloat labelY = 0;
    CGFloat labelH = 32;
    for (int i = 0; i < count; i++) {
        CGFloat labelX = i * labelW;
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(labelX, labelY, labelW, labelH)];
        label.textAlignment = NSTextAlignmentCenter;
        if (i == 0 || i == count - 1) {
            label.textColor = MSThemeColor;
        } else {
            label.textColor     = [UIColor colorWithHexString:@"#444444"];
        }
        label.font          = [UIFont systemFontOfSize:14];
        label.text          = dataSource[i];
        [self addSubview:label];
    }
}

- (void)setShowLine:(BOOL)showLine {
    _showLine = showLine;
}

@end

